<%@ page import="com.utils.CookieUtils" %>
<%
    //拿到所有cookie
    Cookie[] cookies = request.getCookies();

    Cookie username = CookieUtils.findByName(cookies, "username");
    Cookie password = CookieUtils.findByName(cookies, "password");
    Cookie rememberme = CookieUtils.findByName(cookies, "rememberme");

%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
</head>
<body>
<form method="get" action="<%=request.getContextPath() + "/login01.do"%>">
    <%--  对将要调用方法的对象进行判断null，如果不是null才执行。有效避免JSP 500  --%>
    用户名:<input name="username" type="text" <%if (username != null && rememberme != null) {%>
               value="<%=username.getValue()%>"<%}%>/><br>
    密码:<input name="password" type="password" <%if (password != null && rememberme != null) {%>
              value="<%=password.getValue()%>"<%}%>/><br>
    <input type="checkbox" name="rememberme" <%if (rememberme != null) {%> checked="checked" <%}%> >记住我<br>
    <button type="submit">提交</button>
</form>
</body>
</html>
